package databook.util;

import java.util.HashMap;
import java.util.Arrays;
import java.util.Vector;

/**
 *
 * @author zach
 */
public class CustomHash extends HashMap {

    public static final String DELIM = ":";
    
    public String[] getSortedHeaders() {
        String[] keys = (String[])keySet().toArray(new String[0]);
        Arrays.sort(keys);
        return keys;
    }
    
    public String[] getSortedHeaders(String key) {
        Vector<String> v = new Vector();
        String[] headers = getSortedHeaders();
        for (int i = 0; i < headers.length; i++) {
            if (headers[i].startsWith(key)) {
                v.add(headers[i].substring(headers[i].indexOf(":")+1));
            }
        }
        return v.toArray(new String[0]);
    }
    
    public Object put(String prop, String value, Object val) {
        return put(prop + CustomHash.DELIM + value,val);
    }
    
    public boolean containsKey(String key, String val) {
        return containsKey(key + DELIM + val);
    }
    
    public Object get(String key, String val) {
        return get(key + DELIM + val);
    }
    
    public static String getPair(String key, String val) {
        return key + DELIM + val;
    }
}
